﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using WjAutoConfigApp.Properties;

namespace WjAutoConfigApp
{
    
    public partial class frm_Wait_Rotate : Form
    {
        private bool m_exit = false;
        public delegate void CloseEventHandle();
        public CloseEventHandle CloseEvent;
        public frm_Wait_Rotate()
        {
            CheckForIllegalCrossThreadCalls = false;
            InitializeComponent();
            Image image = (Bitmap)Resources.加载状态.Clone();
            pictureBox_Loading.Image = image;
        }
        

        public void CloseWindow()
        {
            //while( this.IsHandleCreated == false)
            //{//窗口还没有装载完毕不能关闭
            //    System.Threading.Thread.Sleep(100);
            //}
            try
            {
                m_exit = true;
                this.TopMost = false;
                this.Hide();
                Application.DoEvents();
                if (CloseEvent != null)
                    CloseEvent.Invoke();
                this.Close();
            }
            catch
            {
            }
            this.DialogResult = DialogResult.OK;
        }
        protected override CreateParams CreateParams
        {
            get
            {
                const int WS_EX_NOACTIVATE = 0x08000000;
                CreateParams cp = base.CreateParams;
                cp.ExStyle |= WS_EX_NOACTIVATE;
                return cp;
            }
        }

        
    }
}
